home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / vardef.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  1KB  |  50 lines

  1.                                       // Chapter 1 - Program 5
  2. #include <iostream.h>
  3.  
  4. int index;
  5.  
  6. main()
  7. {
  8. int stuff;
  9. int &another_stuff = stuff; // A synonym for stuff
  10.  
  11.    stuff = index + 14;      //index was initialized to zero
  12.    cout << "stuff has the value " << stuff << "\n";
  13.    stuff = 17;
  14.    cout << "another_stuff has the value " << another_stuff << "\n";
  15.  
  16. int more_stuff = 13;        //not automatically initialized
  17.  
  18.    cout << "more_stuff has the value " << more_stuff << "\n";
  19.    
  20.    for (int count = 3;count < 8;count++) {
  21.       cout << "count has the value " << count << "\n";
  22.       char count2 = count + 65;
  23.       cout << "count2 has the value " << count2 << "\n";
  24.    }
  25.    
  26. static unsigned goofy;      //automatically initialized to zero
  27.  
  28.    cout << "goofy has the value " << goofy << "\n";
  29. }
  30.  
  31.  
  32.  
  33.  
  34. // Result of execution
  35. //
  36. // stuff has the value 14
  37. // another_stuff has the value 17
  38. // more_stuff has the value 13
  39. // count has the value 3
  40. // count2 has the value D
  41. // count has the value 4
  42. // count2 has the value E
  43. // count has the value 5
  44. // count2 has the value F
  45. // count has the value 6
  46. // count2 has the value G
  47. // count has the value 7
  48. // count2 has the value H
  49. // goofy has the value 0
  50.